package com.qingcheng.controller.order;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qingcheng.pojo.report.CategoryReport;
import com.qingcheng.service.order.CategoryReportService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * @author 岳剑飞
 * @Company http://www.ithiema.com
 */
@RestController
@RequestMapping("/categoryReport")
public class CategoryReportController {
    @Reference
    private CategoryReportService categoryReportService;

    /**
     * 统计上一天的商品类目
     * @return
     */
    @GetMapping("/yesterday")
    public List<CategoryReport> yesterday(){
       // LocalDate localDate = LocalDate.now().minusDays(1);  //得到昨天的日期
        LocalDate localDate = LocalDate.now();  //得到今天的日期
        return categoryReportService.categoryReport(localDate);
    }

    /**
     * 统计一级类目
     * @param beginDate
     * @param endDate
     * @return
     */
    @GetMapping("/category1Count")
    public List<Map> category1Count(String beginDate, String endDate){
      return   categoryReportService.category1Count(beginDate,endDate);
    }
}
